package com.sy.olddriver.dao.impl;

import com.sy.olddriver.dao.OrderDao;
import com.sy.olddriver.utils.DBUtils;
import org.apache.commons.dbutils.QueryRunner;

import java.sql.Connection;
import java.sql.SQLException;

public class OrderDaoImpl implements OrderDao {
    private QueryRunner runner = new QueryRunner();

    @Override
    public int insertOrder(String oid, Integer uid) throws SQLException {
        Connection con = DBUtils.getConnection();
            return runner.update(con, "insert into orders(oid,createtime,uid) values(?,SYSDATE(),?)", oid, uid);
    }

    @Override
    public int insertOrderItem(Integer uid, Integer pid, String oid, Integer count) throws SQLException {
        Connection con = DBUtils.getConnection();
            return runner.update(con, "insert into orderitem(uid,pid,oid,count) values(?,?,?,?)", uid, pid, oid, count);
    }
}
